const { BaseBehavior, COMPONENT_OPTIONS } = require('../../mixins/component');
const { navTo } = require('../../common/platform');
const { PAGE_NAV } = require('../../constants/route');

Component({
    behaviors: [BaseBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        itemInfo: {
            type: Object,
            value: {},
        },
        storeInfo: {
            type: Object,
            value: null,
        },
        size: {
            type: String,
            value: 'middle', // small middle larger column
        },
        isBrand: {
            type: Boolean,
            value: false,
        },
        isHaveAdd: {
            type: Boolean,
            value: false,
        },
        isHaveShadow: {
            type: Boolean,
            value: false,
        },
        isMarginBottom: {
            type: Boolean,
            value: false,
        },
    },
    data: {

    },
    methods: {
        gotoDetail() {
            const { itemInfo, storeInfo } = this.data;
            let param = {
                goodsId: itemInfo.id,
            };
            if (storeInfo) {
                param = {
                    ...param,
                    storeId: storeInfo.id,
                    storeName: storeInfo.name,
                };
            }
            navTo(PAGE_NAV.goodsDetail, param);
        },
    }
})
